﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace Bookvar.UI.Converters
{
    public class ScaledValueConverter : IValueConverter
    {
        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            double scalingFactor = 0;
            if ( parameter == null || !double.TryParse( parameter.ToString(), out scalingFactor ))
            {
                return double.NaN;
            }

            return (double) value * scalingFactor;
        }

        public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
        {
            throw new NotImplementedException( "The method or operation is not implemented." );
        }
    }
}